package com.tanhua.management.controller;

import com.tanhua.management.service.VideoListService;
import com.tanhua.management.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("manage")
public class VideoListController {


    @Autowired
    private VideoListService videoListService;


    /**
     * 查询视频记录列表
     *
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("videos")
    public ResponseEntity<PageResult> queryVideoList(@RequestParam(name = "uid" ) Long uid,
                                                     @RequestParam(name = "pagesize") Integer pageSize,
                                                     @RequestParam(name = "page") Integer page,
                                                     @RequestParam(name = "sortProp") String sortProp,
                                                     @RequestParam(name = "sortOrder") String sortOrder){


        try {

            PageResult pageResult = this.videoListService.queryVideoList(page, pageSize,sortProp, sortOrder,uid);
            if (null != pageResult) {
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

    }

}
